import cx_Oracle

conn = cx_Oracle.connect('fkong/fkong@172.17.23.129/orcl')  
cursor = conn.cursor ()
cursor.execute ("select * from dual")
row = cursor.fetchone ()
print row[0]

cursor.execute ("CREATE TABLE TEST(ID INT, COL1 VARCHAR(32), COL2 VARCHAR(32), COL3 VARCHAR(32))")

cursor.execute ("INSERT INTO TEST (ID, COL1, COL2, COL3)VALUES(1, 'a', 'b', 'c')")
cursor.execute ("INSERT INTO TEST (ID, COL1, COL2, COL3)VALUES(2, 'aa', 'bb', 'cc')")
cursor.execute ("INSERT INTO TEST (ID, COL1, COL2, COL3)VALUES(3, 'aaa', 'bbb', 'ccc')")
conn.commit()

cursor.execute ("SELECT * FROM TEST")
rows = cursor.fetchall()
for row in rows:
	print "%d, %s, %s, %s" % (row[0], row[1], row[2], row[3])

print "Number of rows returned: %d" % cursor.rowcount

cursor.execute ("SELECT * FROM TEST")
while (1):
	row = cursor.fetchone()
	if row == None:
		break
	print "%d, %s, %s, %s" % (row[0], row[1], row[2], row[3])
	
print "Number of rows returned: %d" % cursor.rowcount

cursor.close ()
conn.close ()

